// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import vueScrollBehavior from 'vue-scroll-behavior'

// import MuseUI from 'muse-ui'
// import 'muse-ui/dist/muse-ui.css'
import { AlertPlugin, ConfirmPlugin, ToastPlugin } from 'vux'

import { saveState, throttle } from './utils'

store.subscribe(throttle(() => {
  let state = store.state
  let keys = Object.keys(state)
  keys.forEach(key => {
    saveState(key, state[key])
  })
}, 2000))

Vue.use(AlertPlugin)
Vue.use(ConfirmPlugin)
Vue.use(ToastPlugin)
// Vue.use(MuseUI)
Vue.use(vueScrollBehavior, {router: router})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: {App}
})
